package com.foreveross.vo.common;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.foreveross.common.CommonUtil;

public class FileVo {
	
	private String relativePath;
	private String absolutePath;
	
	public FileVo() {}
	
	public FileVo(String relativePath, String absolutePath) {
		this.relativePath = relativePath;
		this.absolutePath = absolutePath;
	}
	
	public String getRelativePath() {
		return relativePath;
	}
	public void setRelativePath(String relativePath) {
		this.relativePath = relativePath;
	}
	public String getAbsolutePath() {
		return absolutePath;
	}
	public void setAbsolutePath(String absolutePath) {
		
		this.absolutePath = absolutePath;
	}
	
	/**
	 * 多个文件路径处理
	 * @param request
	 * @param relativePaths
	 * @return
	 */
	public static List<FileVo> getFileVoList(HttpServletRequest request, String relativePaths){
		List<FileVo> list = new ArrayList<FileVo>();
		if (null != relativePaths && !"".equals(relativePaths)) {
			String[] relativePathList = relativePaths.split(",");			
			for (String relativePath : relativePathList){
				FileVo fileVo = new FileVo();
				fileVo.setRelativePath(relativePath);
				fileVo.setAbsolutePath(CommonUtil.getHttpBasePath(request) + relativePath);
				list.add(fileVo);
			}
		}
		return list;
	}
	
}
